<template>
  <div id="grandson">
    <h2>我是Grandson组件（孙），数据：{{ name }}---{{ price }}</h2>
  </div>
</template>

<script>
import { toRefs, inject } from "vue";
export default {
  name: "Grandson",
  setup(props) {
    
    // 孙组件通过inject注入数据
    const car = inject("car");

    return {
        ...toRefs(car),
    };
  },
};
</script>

<style scoped>
#grandson {
  padding: 10px;
  background: palevioletred;
}
</style>
